package com.frx.leetoffer.dayone;

/**
 * Created with IDEA
 * 寻找二位数组中是否存在某个元素
 * @author: xrf
 * @Date: 2019/11/17
 * @Time: 11:09
 */
public class FindArrayTest {
    public static void main(String[] args){

    }

    public static boolean isExist(int target,int[][] array){
        int i=0;
        int j = array[i].length-1;
        while (i<array.length && j >=0){
            int val = array[i][j];
            if (target == val){
                return true;
            } else if (target < val){
                j--;
            } else {
                i++;
            }
        }
        return false;
    }
}
